import React from 'react';
import { Switch, Route } from "react-router-dom";
import loadable from "./src/util/loadable";

import Login from './src/page/login/index'
import Authenticate from './src/components/reqAuth';
import './index.css'

const Register = loadable(() => import("./src/page/register/index"));
const viewPaper = loadable(() => import("./src/page/myPaper/viewPaper"));
const Admin = loadable(() => import("./src/page/admin/index"));
const ErrorPage = loadable(() => import("./src/page/admin/errorPage"));

function App() {
  return (
    <div>
      <Switch>
        <Route path="/" exact component={Login} />
        <Route path="/login" exact component={Login} />
        <Route path="/ai_register" exact component={Register} />
        <Route path="/m" component={Authenticate(Admin)} />
        <Route path="/view_p" component={viewPaper} />
        <Route component={ErrorPage}></Route>
      </Switch>
    </div>
  );
}

export default App;
